home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / src / BaseSLList.h < prev    next >
C/C++ Source or Header  |  1996-12-06  |  2KB  |  74 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988, 1992 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. */
  18.  
  19. #ifndef _BaseSLList_h
  20. #define _BaseSLList_h 1
  21.  
  22. #if defined (__GNUG__)
  23. #pragma interface
  24. #endif
  25.  
  26. #undef OK
  27.  
  28. #include <Pix.h>
  29.  
  30. struct BaseSLNode
  31. {
  32.    union {
  33.      struct BaseSLNode *tl;
  34.      double dummy;  /* To force correct alignment */
  35.    };
  36.    void *item() {return (void*)(this+1);} // Return ((SLNode<T>*)this)->hd
  37. };
  38.  
  39. class BaseSLList {
  40.   protected:
  41.     BaseSLNode *last;
  42.     virtual void delete_node(BaseSLNode*node) = 0;
  43.     virtual BaseSLNode* copy_node(const void* datum) = 0;
  44.     virtual void copy_item(void *dst, void *src) = 0;
  45.     virtual ~BaseSLList() { }
  46.     BaseSLList() { last = 0; }
  47.     void copy(const BaseSLList&);
  48.     BaseSLList& operator = (const BaseSLList& a);
  49.     Pix ins_after(Pix p, const void *datum);
  50.     Pix prepend(const void *datum);
  51.     Pix append(const void *datum);
  52.     int remove_front(void *dst, int signal_error = 0);
  53.     void join(BaseSLList&);
  54.   public:
  55.     int length() const;
  56.     int empty() const { return last == 0; }
  57.     void clear();
  58.     Pix                   prepend(BaseSLNode*);
  59.     Pix                   append(BaseSLNode*);
  60.     int                   OK() const;
  61.     void                  error(const char* msg) const;
  62.     void                  del_after(Pix p);
  63.     int                   owns(Pix p) const;
  64.     void                  del_front();
  65. };
  66.  
  67. #endif
  68.  
  69. /*
  70. ;;; Local Variables: ***
  71. ;;; mode: C++ ***
  72. ;;; End: ***
  73. */
  74.